package com.why.jvm.hotspot.src.share.vm.oops;

import lombok.Data;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author xiaoTian
 * @date 2022/7/18 17:45
 * @Description:
 */
@Data
public class CodeAttribute extends AttributeInfo{

    private int maxStack;

    private int maxLocals;

    private int codeLength;

    private byte[] code;

    private int exceptionTableLength;

    private ExceptionTable exceptionTable;

    private int attributesCount;

    private List<AttributeInfo> attributeInfos = new ArrayList<>();

    @Override
    public String toString() {
        StringBuffer s = new StringBuffer( "\n\tCodeAttribute{" +
                "\n\t\tmaxStack=" + maxStack +
                ", \n\t\tmaxLocals=" + maxLocals +
                ", \n\t\tcodeLength=" + codeLength +
                ", \n\t\tcode=" + Arrays.toString(code) +
                ", \n\t\texceptionTableLength=" + exceptionTableLength +
                ", \n\t\texceptionTable=" + exceptionTable +
                ", \n\t\tattributesCount=" + attributesCount);
        attributeInfos.forEach(e->s.append("\t\t\t"+e.toString()+"\n"));
        s.append('}');
        return s.toString();
    }

}
